package com.ruoyi.web.controller.mk;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mk.domain.MkWireless;
import com.ruoyi.mk.service.IMkWirelessService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 终端管理Controller
 * 
 * @author guan
 * @date 2021-12-10
 */
@RestController
@RequestMapping("/mk/wireless")
public class MkWirelessController extends BaseController
{
    @Autowired
    private IMkWirelessService mkWirelessService;

    /**
     * 查询终端管理列表
     */
    @PreAuthorize("@ss.hasPermi('mk:wireless:list')")
    @GetMapping("/list")
    public TableDataInfo list(MkWireless mkWireless)
    {
        startPage();
        List<MkWireless> list = mkWirelessService.selectMkWirelessList(mkWireless);
        return getDataTable(list);
    }

    /**
     * 导出终端管理列表
     */
    @PreAuthorize("@ss.hasPermi('mk:wireless:export')")
    @Log(title = "终端管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MkWireless mkWireless)
    {
        List<MkWireless> list = mkWirelessService.selectMkWirelessList(mkWireless);
        ExcelUtil<MkWireless> util = new ExcelUtil<MkWireless>(MkWireless.class);
        return util.exportExcel(list, "终端管理数据");
    }

    /**
     * 获取终端管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('mk:wireless:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mkWirelessService.selectMkWirelessById(id));
    }

    /**
     * 新增终端管理
     */
    @PreAuthorize("@ss.hasPermi('mk:wireless:add')")
    @Log(title = "终端管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MkWireless mkWireless)
    {
        return toAjax(mkWirelessService.insertMkWireless(mkWireless));
    }

    /**
     * 修改终端管理
     */
    @PreAuthorize("@ss.hasPermi('mk:wireless:edit')")
    @Log(title = "终端管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MkWireless mkWireless)
    {
        return toAjax(mkWirelessService.updateMkWireless(mkWireless));
    }

    /**
     * 删除终端管理
     */
    @PreAuthorize("@ss.hasPermi('mk:wireless:remove')")
    @Log(title = "终端管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mkWirelessService.deleteMkWirelessByIds(ids));
    }
}
